<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>作用域插槽</title>
        <script src="../public/vue2.7.14-dev.js"></script>
    </head>
    <body>
        <div id="app">
            <!-- 通过prop可以解决作用域的问题 -->
            <current-user :user="user"><!-- 用prop进行传值！ -->
                <template v-slot:first>
                    {{ user.firstName }}--
                </template>

                <template v-slot:last>
                  <!-- kong -->
                </template>
            </current-user>
        </div>

        
        <script>
        Vue.component('current-user',{
            template:`
            <span>
                <slot name="first"></slot>
                <slot name="last">--{{ user.lastName }}</slot>
            </span>
            `,
            props:['user']
        })

        new Vue({
            el:'#app',
            data(){
                return {
                    user:{
                        firstName:"luo",
                        lastName:'yu'
                    }
                }
            }
        })
    </script>
    </body>
</html>